jclass={
    initPage:function(){
        // 绑定dom对象
        this.obj = {
            searchText:$('#searchText'),
        };
        // 声明全局变量
        this.data = {
            datatable:[],
            tableParams: {
                platformId: '',
                platformName    : '',
                handleBeginTime: '',
                handleEndTime: '',
                page:1,
                size:10,
                commandCode: "0x9302"
            }
        };
        this.getTableList();
        // this.creatTable();
        this.init();
        this.bindEvent();
    },
    init() {
        let that = this
        //十分年月日范围
        $('.J-datepickerTime-range').datePicker({
            format: 'YYYY-MM-DD HH:mm',
            isRange: true,
            hide: function (type) {
                // console.info(this.$input.eq(0).val(), this.$input.eq(1).val());
                that.data.tableParams.handleBeginTime = this.$input.eq(0).val()
                that.data.tableParams.handleEndTime = this.$input.eq(1).val()
            }
        });

        // 重置
        $("#resetClick").click(() => {
            $("#search_input_platfrom").val("")
            $("#search_time input").val("")

            this.data.tableParams = {
                platformId: '',
                platformName    : '',
                handleBeginTime: '',
                handleEndTime: '',
                page:1,
                size:10,
                commandCode: "0x9302"
            }
        })

        // 查询
        $("#searchClick").click(() => {
            this.data.tableParams.page = 1;
            this.data.tableParams.size = 10;
            this.getTableList()
        })

        $("select").prop("selectedIndex",-1)
        $("select").find("option").each(function() {
            $(this).removeAttr("selected");
        });

        // $("#dPlatformInput").on("change", function(e) {
        //     console.log('change')
        // })

         $("#objectSelect option:first").attr("selected",true)
        
    },
    bindEvent() {
        
    },
    getTableList() {
        $("#jid_loading").show()
        this.data.tableParams.platformName = $("#search_input_platfrom").val()
        jrequest.get("/api/commd-send/findAllChagang",this.data.tableParams).then(res => {
            this.data.datatable = res.data
            $("#jtable_notice").bootstrapTable('destroy');
            this.creatTable(res)
            $("#jid_loading").hide()
            // $("#jtable_notice").bootstrapTable('load',res.data);
        })
    },
    tableEvent:function(id,data,columns,paginationShow,total){
        let that = this
        $('#' + id).bootstrapTable({
            method: 'get',
            cache: false,
            height: 320,
            pagination: paginationShow,
            pageSize: that.data.tableParams.size,
            pageNumber:that.data.tableParams.page,
            showColumns: true,
            striped: true,
            columns: columns,
            sidePagination: 'server', // client or server
            totalRows: total,
            data :data,
            onPageChange: function (size, number) {
                console.log(number)
                that.data.tableParams.page = number
                that.data.tableParams.size = size
                that.getTableList()
            },
            formatNoMatches: function(){
                return '暂无数据';
            }
        });
    },
    creatTable:function(res){
        var self=this;
        var columnsOne = [
            {
                title : '序号',
                align: "center",
                formatter: function (value, row, index) {
                    //获取每页显示的数量
                    var pageSize=self.data.tableParams.size;
                    //获取当前是第几页
                    var pageNumber=self.data.tableParams.page;
                    //返回序号，注意index是从0开始的，所以要加上1
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },
            {
              field: "platformName",
              title: "运营商平台",
              visible: true
            },
            {
              field: "checkTheTime",
              title: "发布时间",
              visible: true
            },
            {
              field: "sendContent",
              title: "发布信息",
              visible: true
            },
            {
              field: "objectId",
              title: "对象类型",
              visible: true
            },
            {
              field: "objectType",
              title: "公告对象",
              visible: true
            },
            {
              field: "platforType",
              title: "下级应答状态",
              visible: true
            }
        ];
        self.tableEvent("jtable_notice",res.data,columnsOne,true,res.total);
    }
}

$(function(){
    jclass.initPage();
});